// 实验vue
		new Vue({
			el: "#thisDivs",
			data: {
				divImgs: ["https://showtp.oss-cn-chengdu.aliyuncs.com/books/images/oneDiv.jpg",
				"https://showtp.oss-cn-chengdu.aliyuncs.com/books/images/twoDiv.jpg",
				"https://showtp.oss-cn-chengdu.aliyuncs.com/books/images/threeDiv.jpg",
				"https://showtp.oss-cn-chengdu.aliyuncs.com/books/images/fourDiv.jpg"]
			},
			methods: {
				aler(){
					// alert("xss")
					console.log("xss");
				}
			}
		});


		var thisWidth;
		var thisHeight;
		var $docHei;

		console.log(window.innerWidth);
		console.log(window.innerHeight);
	
		// 通过滚轮调用事件
		$(window).scroll(function(){

			thisWidth = window.innerWidth;
			thisHeight = window.innerHeight;
			$docHei = $(document).height();


			$("#backGr").height($docHei)
			
			var theNav = document.getElementById("nav");
			var theA = theNav.getElementsByTagName("a");
			
			// 设置当屏幕改变时更改文字
			for(var i = 0; i < theA.length; i++){
				if(thisWidth < 960){
					theA[0].innerText = "Kindle区";
					theA[1].innerText = "PDF区";
					theA[2].innerText = "计算机区";
					theA[3].innerText = "书库";
					theA[4].innerText = "登录";
				}
				if(thisWidth > 960){
					theA[0].innerText = "—— Kindle区 ——";
					theA[1].innerText = "—— PDF区 ——";
					theA[2].innerText = "—— 计算机区 ——";
					theA[3].innerText = "—— 书库 ——";
					theA[4].innerText = "—— 登录 ——";
				}		
			}

			// 用arguments接收形参
			theScroll($("#oneDiv"),$("#twoDiv"),$("#threeDiv"),$("#fourDiv"),$("#oneSpan"),$("#twoSpan"),$("#threeSpan"),$("#fourSpan"));
			function theScroll(){
				if(thisWidth > 767){
					for(var ag = 0; ag < arguments.length; ag++){
						var targetHeight = arguments[ag].offset().top;
						var scrollTop = $(window).scrollTop();
						if(scrollTop > targetHeight-600){
							arguments[ag].animate({opacity:1},1200);
						}
					}
				}
			}
		})

		console.log($docHei);

		showLogin()

		$(window).resize(function(){
            showLogin();
        });

		// 返回顶部
		function doType(){
			var fuheight = ($(document).height()) * -1;
			$("html,body").animate({
					scrollTop: 0
			},200);
		}

		// 通过当前浏览器窗口来改变模态框的位置
		function showLogin(){
            var $winW = $(window).width();
            var $winH = $(window).height();

            var $thisw = $("#login").outerWidth();
            var $thish = $("#login").outerHeight();

            $("#login").css({"left":($winW - $thisw)/2 + "px","top":($winH - $thish)/2 + "px"});
        };

        // 点击登录
        $("#navA").click(function(){
			$("#backGr").fadeIn(800).css("display","block");
			$("#login").fadeIn(800).css("display","block");
			$("#firstForm").css("display","block");
			$("#secondForm").css("display","none");
			$("body").css("overflow","hidden")
			doType();
		});

		// 点击登录关闭
		$("#close").click(function(){
			$("#backGr").css("display","none");
			$("#login").css("display","none");
			$("body").css("overflow","visible")
			$("#login form span").empty();
			$("#login input").css("borderColor","#333")
		})

		// 点击跳转到注册
		$("#doZc").click(function(){
			$("#firstForm").css("display","none")
			$("#secondForm").css("display","block")
		});

		// 点击回到登录
		$("#returnLogin").click(function(){
			$("#firstForm").css("display","block")
			$("#secondForm").css("display","none")
		})

		// 判断登录用户名
		var dlUser = document.getElementById("user");
		dlUser.onblur = ()=>{
			var dlUserZ = /^[0-9a-zA-Z][0-9a-zA-Z_.-]{2,16}[0-9a-zA-Z]$/;
			var dlUserV = document.getElementById("user").value;
			var dlUserS = document.getElementById("oneDlSpan");
			if (!dlUserZ.test(dlUserV)) {
				dlUser.style.borderColor = "#f00";
				dlUserS.innerHTML = "&#10006";
				dlUserS.style.color = "#f00";

				return false;
			}
			dlUser.style.borderColor = "#333";
			dlUserS.innerHTML = "&#10004";
			dlUserS.style.color = "#53ff53";
			return true;
		}
		// 判断登录密码
		var dlPassword = document.getElementById("dlPassword");
		dlPassword.onblur = ()=>{
			var dlPasswordZ = /^[a-zA-Z0-9]{4,10}$/;
			var dlPasswordV = document.getElementById("dlPassword").value;
			var dlPasswordS = document.getElementById("twoDlSpan");
			if (!dlPasswordZ.test(dlPasswordV)) {
				dlPassword.style.borderColor = "#f00";
				dlPasswordS.innerHTML = "&#10006";
				dlPasswordS.style.color = "#f00";

				return false;
			}
			dlPassword.style.borderColor = "#333";
			dlPasswordS.innerHTML = "&#10004";
			dlPasswordS.style.color = "#53ff53";
			return true;
		}
		// 判断注册名
		var zcfirstName = document.getElementById("firstName");
		zcfirstName.onblur = ()=>{
			var zcfirstNameZ = /^[0-9a-zA-Z][0-9a-zA-Z_.-]{2,16}[0-9a-zA-Z]$/;
			var zcfirstNameV = document.getElementById("firstName").value;
			var zcfirstNameS = document.getElementById("oneZcSpan");
			if (!zcfirstNameZ.test(zcfirstNameV)) {
				zcfirstName.style.borderColor = "#f00";
				zcfirstNameS.innerHTML = "&#10006";
				zcfirstNameS.style.color = "#f00";

				return false;
			}
			zcfirstName.style.borderColor = "#333";
			zcfirstNameS.innerHTML = "&#10004";
			zcfirstNameS.style.color = "#53ff53";
			return true;
		}
		var zclastName = document.getElementById("lastName");
		zclastName.onblur = ()=>{
			var zclastNameZ = /^[0-9a-zA-Z][0-9a-zA-Z_.-]{2,16}[0-9a-zA-Z]$/;
			var zclastNameV = document.getElementById("lastName").value;
			var zclastNameS = document.getElementById("twoZcSpan");
			if (!zclastNameZ.test(zclastNameV)) {
				zclastName.style.borderColor = "#f00";
				zclastNameS.innerHTML = "&#10006";
				zclastNameS.style.color = "#f00";

				return false;
			}
			zclastName.style.borderColor = "#333";
			zclastNameS.innerHTML = "&#10004";
			zclastNameS.style.color = "#53ff53";
			return true;
		}
		// 判断注册邮箱
		var zcEmail = document.getElementById("zcEmail");
		zcEmail.onblur = ()=>{
			var zcEmailZ = /^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$/;
			var zcEmailV = document.getElementById("zcEmail").value;
			var zcEmailS = document.getElementById("fourZcSpan");
			if (!zcEmailZ.test(zcEmailV)) {
				zcEmail.style.borderColor = "#f00";
				zcEmailS.innerHTML = "&#10006";
				zcEmailS.style.color = "#f00";

				return false;
			}
			zcEmail.style.borderColor = "#333";
			zcEmailS.innerHTML = "&#10004";
			zcEmailS.style.color = "#53ff53";
			return true;
		}
		// 判断注册密码
		var zcPassword = document.getElementById("zcPassword");
		zcPassword.onblur = ()=>{
			var zcPasswordZ = /^[a-zA-Z0-9]{4,10}$/;
			var zcPasswordV = document.getElementById("zcPassword").value;
			var zcPasswordS = document.getElementById("fiveZcSpan");
			if (!zcPasswordZ.test(zcPasswordV)) {
				zcPassword.style.borderColor = "#f00";
				zcPasswordS.innerHTML = "&#10006";
				zcPasswordS.style.color = "#f00";

				return false;
			}
			zcPassword.style.borderColor = "#333";
			zcPasswordS.innerHTML = "&#10004";
			zcPasswordS.style.color = "#53ff53";
			return true;
		}
		// 判断注册手机号
		var zcNumber = document.getElementById("zcNumber");
		zcNumber.onblur = ()=>{
			var zcNumberZ = /^(13|15|18)\d{9}$/;
			var zcNumberV = document.getElementById("zcNumber").value;
			var zcNumberS = document.getElementById("sixZcSpan");
			if (!zcNumberZ.test(zcNumberV)) {
				zcNumber.style.borderColor = "#f00";
				zcNumberS.innerHTML = "&#10006";
				zcNumberS.style.color = "#f00";

				return false;
			}
			zcNumber.style.borderColor = "#333";
			zcNumberS.innerHTML = "&#10004";
			zcNumberS.style.color = "#53ff53";
			return true;
		}

		//绑定键盘事件  按下esc键退出
        $(document).keyup(function(ev){
            if(ev.keyCode == 27){
            	$("span#close").trigger("click");
            }
        })

		var i = 0 ;
		var timer;
		var bookIndex;
		showTime();
		
		// 轮播图
		$(".theSj img").eq(0).show().siblings(".theSj img").hide();
		function showTime(){
			timer = setInterval(function(){
		    	Show();
			    $.ajax({
					type: "get",
					url: "../json/indexNav.json",
					dataType: "json",
					success: function(data){
						// 将data转换成全局变量
						bookIndex = data;
						$("#leftText p").text(data[i].text);
						$("#theHref")[0].href = data[i].url;
						var theImg = "<img src='" + data[i].img + "'/ >";
						$("#theHref").append(theImg);
					}
				});
				i++;
				if(i == 6)i = 0;
		  	},2000);
		}

		// 当hover事件发生时
		$(".theLi").hover(function(){
		    i = $(this).index();
		    $(this).css("backgorundColor","#000");
		    if(i == 5)i = 0;
		    $("#leftText p").text(bookIndex[i+1].text);
		    var theImg = "<img src='" + bookIndex[i+1].img + "'/ >";
			$("#theHref").append(theImg);
		    Show();
		    clearInterval(timer);
		},function(){
			showTime();
		});
		 	
		// 轮播图样式
		function Show(){
		  $(".theLi").eq(i).css("backgroundColor","rgba(255,255,255,.5)").siblings(".theLi").css("backgroundColor","rgba(0,0,0,0)");
		  $(".theSj img").eq(i).fadeIn(1000).siblings(".theSj img").fadeOut(1000);
		 
		}

		// 获取下方盒子的文字,URL
		$.ajax({
			type: "get",
			url: "../json/indexDiv.json",
			dataType: "json",
			success: function(names){
				var $theFe = $(".boxStyleRight");

				if($theFe[0].id == "scetionss")doChangeBooks(names[0],$("#scetionss"));
				if($theFe[1].id == "history")doChangeBooks(names[1],$("#history"));
				if($theFe[2].id == "masterwork")doChangeBooks(names[2],$("#masterwork"));
				if($theFe[3].id == "philosophy")doChangeBooks(names[3],$("#philosophy"));

				function doChangeBooks(obj,id){
					for(var g in obj){
						for(var h in obj[g]){
							var thisBooks = "<a href='" + obj[g][h].url + "' />" + obj[g][h].name + "</a>";
							id.append(thisBooks);
						}
					}
				}
			}
		});